package com.maila.xiaoaodispatch.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.maila.xiaoaodispatch.R;
import com.maila.xiaoaodispatch.entity.OrderData;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 未完成
 * Created by Administrator on 2017/11/2.
 */

public class MyOrderAdapter extends BaseAdapter {
    Context context;
    List<OrderData.DataBean> mdata;
    public MyOrderAdapter(Context context) {
        this.context = context;
        mdata=new ArrayList<>();
    }

    public List<OrderData.DataBean> getMdata() {
        return mdata;
    }

    public void setMdata(List<OrderData.DataBean> mdata) {
        this.mdata = mdata;
    }
    public void addMdata(List<OrderData.DataBean> mdata) {
        this.mdata.addAll(mdata);
    }
    @Override
    public int getCount() {
        return mdata.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_myorder, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        if(i==0){
            holder.rlDaijiedan.setBackgroundResource(R.drawable.bg_circle_orange);
            holder.tvStepOne.setText("已接单");
            holder.tvStepTwo.setText("取货");
            holder.tvStepThree.setText("送达");
            holder.btnTakeOrder.setText("到店");
        }else if(i==1){
            holder.rlDaijiedan.setBackgroundResource(R.drawable.bg_circle_orange);
            holder.rlQujian.setBackgroundResource(R.drawable.bg_circle_orange);
            holder.rlComplete.setBackgroundResource(R.drawable.bg_circle_gray);
            holder.tvStepOne.setText("已接单");
            holder.tvStepTwo.setText("取件");
            holder.tvStepThree.setText("送达");
            holder.btnTakeOrder.setText("送达");
        }else {
            holder.rlDaijiedan.setBackgroundResource(R.drawable.bg_circle_orange);
            holder.rlQujian.setBackgroundResource(R.drawable.bg_circle_orange);
            holder.rlComplete.setBackgroundResource(R.drawable.bg_circle_gray);
            holder.tvStepOne.setText("已接单");
            holder.tvStepTwo.setText("取件");
            holder.tvStepThree.setText("发件");
            holder.btnTakeOrder.setText("反馈信息");
        }
        return view;
    }


    static class ViewHolder {
        @BindView(R.id.tv_send)
        TextView tvSend;
        @BindView(R.id.tv_get)
        TextView tvGet;
        @BindView(R.id.tv_express)
        TextView tvExpress;
        @BindView(R.id.btn_connect_shop)
        AutoLinearLayout btnConnectShop;
        @BindView(R.id.btn_connect_clint)
        AutoLinearLayout btnConnectClint;
        @BindView(R.id.rl_daijiedan)
        AutoRelativeLayout rlDaijiedan;
        @BindView(R.id.tv_step_one)
        TextView tvStepOne;
        @BindView(R.id.rl_qujian)
        AutoRelativeLayout rlQujian;
        @BindView(R.id.tv_step_two)
        TextView tvStepTwo;
        @BindView(R.id.rl_complete)
        AutoRelativeLayout rlComplete;
        @BindView(R.id.tv_step_three)
        TextView tvStepThree;
        @BindView(R.id.btn_take_order)
        TextView btnTakeOrder;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
